function record_option()
{	
}

record_option.prototype= 
{
		toggleRadioButton:function()
		{
	if(document.getElementById('local').selected)
	{
		document.getElementById('local-file-name').removeAttribute("disabled");
		document.getElementById('stream-server-address').setAttribute("disabled",'true');
		document.getElementById('stream-port-no').setAttribute("disabled",'true');	
		document.getElementById('stream-password').setAttribute("disabled",'true');
		document.getElementById('stream-mount-point').setAttribute("disabled",'true');
	}
	else
	{
		document.getElementById('local-file-name').setAttribute("disabled",'true');
		document.getElementById('stream-server-address').removeAttribute("disabled");
		document.getElementById('stream-port-no').removeAttribute("disabled");
		document.getElementById('stream-password').removeAttribute("disabled");
		document.getElementById('stream-mount-point').removeAttribute("disabled");
	}
		},
		loaddialog:function()
		{
			var firefoggId = "fireice@abhinav.chittora";
			var em = Components.classes["@mozilla.org/extensions/manager;1"]
			                            .getService(Components.interfaces.nsIExtensionManager);
			var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
			                                    .getService(Components.interfaces.nsIXULRuntime);
			var exec_name = "content";
			var cmd = em.getInstallLocation(firefoggId).getItemFile(firefoggId, exec_name);
			cmd.append("fireice.sqlite");
			var storageService = Components.classes["@mozilla.org/storage/service;1"]
			                                        .getService(Components.interfaces.mozIStorageService);
			var mDBConn = storageService.openDatabase(cmd); 
			var q="SELECT * FROM fireice_server WHERE isdefault='true'";
			var statement = mDBConn.createStatement(q);
			try 
			{	
				statement.executeAsync(
						{	
							handleResult: function(aResultSet) 
							{	
							for (let row = aResultSet.getNextRow();	row; row = aResultSet.getNextRow()) 
							{


								var server_add = row.getResultByName("server_add");
								var server_port = row.getResultByName("port");
								var server_pass = row.getResultByName("password");
								var server_mount = row.getResultByName("mount_point");
								//alert(server_add);
								if(server_add=="" || server_port=="" || server_pass=="" || server_mount=="")
								{
									alert("Error in Database");
								}
								else
								{
									document.getElementById('stream-server-address').setAttribute('value',server_add);
									document.getElementById('stream-port-no').setAttribute('value',server_port);
									document.getElementById('stream-password').setAttribute('value',server_pass);
									document.getElementById('stream-mount-point').setAttribute('value',server_mount);
								}	
							}
							},

							handleError: function(aError) 
							{
								print("Error: " + aError.message);
							},

							handleCompletion: function(aReason) 
							{
								if (aReason != Components.interfaces.mozIStorageStatementCallback.REASON_FINISHED)
									print("Query canceled or aborted!");
							}
						});
			}
			finally 
			{
				statement.reset();
			}

		}

}

var opt= new record_option();

